package com.gopay.checkorder.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gopay.checkorder.manager.BankAuthOrderManager;
import com.gopay.checkorder.service.BankAuthOrderService;
import com.gopay.common.constants.bank.BankAuthOrderStatus;
import com.gopay.common.domain.bank.BankAuthOrder;
import com.gopay.common.domain.bank.BaseMessage;
import com.gopay.common.exception.GopayException;
/** 
 * 委托代收认证主订单Service实现
 * @ClassName: BankAuthOrderServiceImpl 
 * @author lilili
 * @date 2017年2月19日 下午1:41:14  
 */ 
@Service("bankAuthOrderService")
public class BankAuthOrderServiceImpl implements BankAuthOrderService {

	@Resource(name = "bankAuthOrderManager")
    private BankAuthOrderManager bankAuthOrderManager;
	
	  @Override
	    public int updateAutoQuerySuccess(BaseMessage base) throws GopayException{
	        BankAuthOrder authOrder = new BankAuthOrder();
	        authOrder.setOrderId(base.getOrderId());
	        authOrder.setOrderStatus(BankAuthOrderStatus.AUTO_CHECK_SUCCESS);
	        int result = bankAuthOrderManager.updateAutoQuerySuccess(authOrder);
	        return result;
	    }

	    @Override
	    public int updateBackVerifyFail(BaseMessage base) throws GopayException{
	        BankAuthOrder authOrder = new BankAuthOrder();
	        authOrder.setOrderId(base.getOrderId());
	        authOrder.setOrderStatus(BankAuthOrderStatus.AUTH_VERIFY_FAIL);
	        int result = bankAuthOrderManager.updateBackVerifyFail(authOrder);
	        return result;
	    }

	    @Override
	    public int updateAutoQueryFail(BaseMessage base) throws GopayException{
	        BankAuthOrder authOrder = new BankAuthOrder();
	        authOrder.setOrderId(base.getOrderId());
	        authOrder.setOrderStatus(BankAuthOrderStatus.AUTO_CHECK_FAIL);
	        int result = bankAuthOrderManager.updateAutoQueryFail(authOrder);
	        return result;
	    }

}
